package com.gewu.pm.ui.fragment.sales;

import android.widget.TextView;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.gewu.pm.R;
import com.gewu.pm.app.AppFragment;
import com.gewu.pm.ui.adapter.sales.VisitRecordAdapter;

import java.util.ArrayList;
import java.util.List;

/**
 * 销售线索拜访记录 Fragment
 */
public final class SalesLeadVisitRecordFragment extends AppFragment<com.gewu.pm.app.AppActivity> {

    private TextView mStartDateView;
    private TextView mEndDateView;
    private RecyclerView mRecyclerView;
    private VisitRecordAdapter mAdapter;

    public static SalesLeadVisitRecordFragment newInstance() {
        return new SalesLeadVisitRecordFragment();
    }

    @Override
    protected int getLayoutId() {
        return R.layout.sales_lead_visit_record_fragment;
    }

    @Override
    protected void initView() {
        mStartDateView = findViewById(R.id.tv_start_date);
        mEndDateView = findViewById(R.id.tv_end_date);
        mRecyclerView = findViewById(R.id.rv_visit_record);

        // 设置 RecyclerView
        mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
        mAdapter = new VisitRecordAdapter(getContext());
        mRecyclerView.setAdapter(mAdapter);
    }

    @Override
    protected void initData() {
        // 简化版：添加测试数据（只有拜访人名字）
        List<String> visitorNames = new ArrayList<>();
        visitorNames.add("陈宏伟");
        visitorNames.add("陈宏伟");
        visitorNames.add("张三");
        visitorNames.add("李四");
        mAdapter.setData(visitorNames);
    }

    /**
     * 更新拜访记录数据
     * 
     * @param visitorNames 拜访人名字列表
     */
    public void updateData(List<String> visitorNames) {
        if (mAdapter != null) {
            mAdapter.setData(visitorNames);
        }
    }
}

